#ifndef TRACKSEGMENT_H
#define TRACKSEGMENT_H

#include <QGraphicsPathItem>
#include <QPainterPath>
#include <QPen>
#include <QBrush>
#include <QColor>
#include <QPointF>

class TrackSegment : public QGraphicsPathItem
{
public:
    enum SegmentType {
        Straight,
        Arc
    };

    TrackSegment(SegmentType type, QGraphicsItem* parent = nullptr);
    virtual ~TrackSegment() = default;

    SegmentType segmentType() const { return m_type; }
    
    virtual double length() const = 0;
    virtual QPointF getPointAt(double distance) const = 0;
    virtual double getAngleAt(double distance) const = 0;
    
    virtual void updatePath() = 0;
    
    void setTrackWidth(double width) { m_trackWidth = width; updatePath(); }
    double trackWidth() const { return m_trackWidth; }
    
    void setColor(const QColor& color) { m_color = color; update(); }
    QColor color() const { return m_color; }
    
    virtual void setLength(double length) { Q_UNUSED(length) }
    virtual void setRadius(double radius) { Q_UNUSED(radius) }
    virtual void setAngle(double angle) { Q_UNUSED(angle) }

protected:
    SegmentType m_type;
    double m_trackWidth;
    QColor m_color;
};

#endif // TRACKSEGMENT_H
